#include "stdint.h"
#include "stdio.h"
#include "string.h"
#include "DevicesPWM.h"


void vPWM0Init(void)
{
    ledc_timer_config_t ledc_timer = {0};
    // ledc_channel_config_t ledc_channel = {0};

    /* Prepare and then apply the LEDC PWM timer configuration */
    ledc_timer.speed_mode       = LEDC_LOW_SPEED_MODE;
    ledc_timer.duty_resolution  = LEDC_TIMER_12_BIT;
    ledc_timer.timer_num        = LEDC_TIMER_0;
    ledc_timer.freq_hz          = 4000;
    ledc_timer.clk_cfg          = LEDC_AUTO_CLK;
    ledc_timer.deconfigure      = 0;
    ledc_timer_config(&ledc_timer);

    /* 在通道使用处再初始化 */
    // /* Prepare and then apply the LEDC PWM channel configuration */
    // ledc_channel.gpio_num       = GPIO_NUM_8;
    // ledc_channel.speed_mode     = LEDC_LOW_SPEED_MODE;
    // ledc_channel.channel        = LEDC_CHANNEL_0;
    // ledc_channel.intr_type      = LEDC_INTR_DISABLE;
    // ledc_channel.timer_sel      = LEDC_TIMER_0;
    // ledc_channel.duty           = 0;
    // ledc_channel.hpoint         = 0;
    // ledc_channel_config(&ledc_channel);

    // /* Set duty to 0% */
    // ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, 0);
    // /* Update duty to apply the new value */
    // ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
}

void vPWM1Init(void)
{
    ledc_timer_config_t ledc_timer = {0};

    /* Prepare and then apply the LEDC PWM timer configuration */
    ledc_timer.speed_mode       = LEDC_LOW_SPEED_MODE;
    ledc_timer.duty_resolution  = LEDC_TIMER_13_BIT;
    ledc_timer.timer_num        = LEDC_TIMER_1;
    ledc_timer.freq_hz          = 4000;
    ledc_timer.clk_cfg          = LEDC_AUTO_CLK;
    ledc_timer.deconfigure      = 0;
    ledc_timer_config(&ledc_timer);
}
